package cn.yangliu.nacos.management.model;

import java.util.List;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import static cn.yangliu.nacos.management.constant.ManagementValidateConstants.OAUTH2CLIENT_ACCESSTOKENVALIDITYSECONDS_ILLEGAL;
import static cn.yangliu.nacos.management.constant.ManagementValidateConstants.OAUTH2CLIENT_ACCESSTOKENVALIDITYSECONDS_MISS;
import static cn.yangliu.nacos.management.constant.ManagementValidateConstants.OAUTH2CLIENT_GRANTTYPES_MISS;
import static cn.yangliu.nacos.management.constant.ManagementValidateConstants.OAUTH2CLIENT_NAME_MISS;
import static cn.yangliu.nacos.management.constant.ManagementValidateConstants.OAUTH2CLIENT_REFRESHTOKENVALIDITYSECONDS_ILLEGAL;
import static cn.yangliu.nacos.management.constant.ManagementValidateConstants.OAUTH2CLIENT_REFRESHTOKENVALIDITYSECONDS_MISS;
import static cn.yangliu.nacos.management.constant.ManagementValidateConstants.OAUTH2CLIENT_SCOPES_MISS;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2020 -01-01
 */
@Data
public class ClientInsertModel {

    /**
     * current class instance's member.
     * The Access token validity seconds.
     */
    @ApiModelProperty(value = "token失效时间", required = true, example = "1")
    @NotNull(message = OAUTH2CLIENT_ACCESSTOKENVALIDITYSECONDS_MISS)
    @Range(min = 1, max = 60 * 60 * 24 * 90,
            message = OAUTH2CLIENT_ACCESSTOKENVALIDITYSECONDS_ILLEGAL)
    private Long accessTokenValiditySeconds;

    /**
     * current class instance's member.
     * The Description.
     */
    @ApiModelProperty(value = "描述", example = "1")
    private String description;

    /**
     * current class instance's member.
     * The Grant types.
     */
    @ApiModelProperty(value = "授权方式", required = true, example = "password")
    @NotBlank(message = OAUTH2CLIENT_GRANTTYPES_MISS)
    private String grantTypes;

    /**
     * current class instance's member.
     * The Icon uri.
     */
    @ApiModelProperty(value = "图标", example = "xxx")
    private String iconUri;

    /**
     * current class instance's member.
     * The Name.
     */
    @ApiModelProperty(value = "客户端名称", required = true, example = "腾讯")
    @NotBlank(message = OAUTH2CLIENT_NAME_MISS)
    private String name;

    /**
     * current class instance's member.
     * The Redirect uris.
     */
    @ApiModelProperty(value = "重定向url,多个用,分割", required = true, example = "http://www.baidu.com")
    private String redirectUris;

    /**
     * current class instance's member.
     * The Refresh token validity seconds.
     */
    @ApiModelProperty(value = "刷新token失效时间", required = true, example = "1")
    @NotNull(message = OAUTH2CLIENT_REFRESHTOKENVALIDITYSECONDS_MISS)
    @Range(min = 1, max = 60 * 60 * 24 * 90,
            message = OAUTH2CLIENT_REFRESHTOKENVALIDITYSECONDS_ILLEGAL)
    private Long refreshTokenValiditySeconds;

    /**
     * current class instance's member.
     * The Scopes.
     */
    @ApiModelProperty(value = "授权范围", required = true, example = "all")
    @NotBlank(message = OAUTH2CLIENT_SCOPES_MISS)
    private String scopes;

    /**
     * current class instance's member.
     * The Role ids.
     */
    @ApiModelProperty(value = "角色id", required = true, example = "1")
    private List<Long> roleIds;

}
